<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8" />
    <title>4-4 常量如何取值</title>
</head>
<body>
<div align="center">
    <p><a href="index.php"><font size="4">目录</font></a></p>
    <?php
    $p="";

    //定义圆周率的两种值
    define("PI1",3.14);
    define("PI2",3.142);

    //定义值得精度。
    $height = "低";

    //根据精度返回常量名，将常量变成了一个可变的常量
    if($height == "中"){
        $p = "PI1";
    }else if($height == "低"){
        $p = "PI2";
    }
    $r=1;
    $area=constant($p)*$r*$r; //计算圆周率面积
    echo $area;
    ?>

    <!--总结：

    -->
</div>
</body>
</html>